﻿<%@ Page Language="C#" MasterPageFile="~/Site.master" CodeBehind="List.aspx.cs" Inherits="DD_Bootstrap.Territories.List" %>

<asp:Content ID="headContent" ContentPlaceHolderID="head" runat="Server">
</asp:Content>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:DynamicDataManager ID="DynamicDataManager1" runat="server" AutoLoadForeignKeys="true">
        <DataControls>
            <asp:DataControlReference ControlID="GridView1" />
        </DataControls>
    </asp:DynamicDataManager>

    <h2 class="DDSubHeader"><%= table.DisplayName%></h2>

    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <div class="form-inline form-actions">
                <asp:ValidationSummary ID="ValidationSummary1" runat="server" EnableClientScript="true"
                    HeaderText="List of validation errors" CssClass="error" />
                <asp:DynamicValidator runat="server" ID="GridViewValidator" ControlToValidate="GridView1" Display="None" CssClass="error" />

                <asp:QueryableFilterRepeater runat="server" ID="FilterRepeater">
                    <ItemTemplate>
                        <asp:Label runat="server" Text='<%# Eval("DisplayName") %>' OnPreRender="Label_PreRender" />
                        <asp:DynamicFilter runat="server" ID="DynamicFilter" OnFilterChanged="DynamicFilter_FilterChanged" />
                    </ItemTemplate>
                </asp:QueryableFilterRepeater>
            </div>

            <asp:GridView
                ID="GridView1"
                runat="server"
                DataSourceID="GridDataSource"
                EnablePersistedSelection="true"
                OnPreRender="GridView1_PreRender"
                AllowPaging="True"
                AllowSorting="True"
                CssClass="table table-striped table-bordered table-hover"
                BorderStyle="NotSet" 
                OnRowCommand="GridView1_RowCommand">
                <Columns>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:DynamicHyperLink 
                                runat="server" 
                                Action="Edit" 
                                Text="Edit"/>&nbsp;
                            <asp:LinkButton 
                                runat="server" 
                                CommandName="Delete" 
                                Text="Delete" 
                                OnClientClick='return confirm("Are you sure you want to delete this item?");'/>&nbsp;
                            <asp:DynamicHyperLink 
                                runat="server" 
                                Text="Details"/>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>

                <PagerStyle CssClass="pagination pull-right" />
                <PagerSettings
                    Mode="NumericFirstLast"
                    PageButtonCount="5"
                    FirstPageText="&lt;i class=&quot;icon-step-backward&quot;&gt;&lt;/i&gt;"
                    LastPageText="&lt;i class=&quot;icon-step-forward&quot;&gt;&lt;/i&gt;"
                    NextPageText="&lt;i class=&quot;icon-forward&quot;&gt;&lt;/i&gt;"
                    PreviousPageText="&lt;i class=&quot;icon-backward&quot;&gt;&lt;/i&gt;" />
                <EmptyDataTemplate>
                    There are currently no items in this table.
                </EmptyDataTemplate>
            </asp:GridView>

            <asp:EntityDataSource ID="GridDataSource" runat="server" EnableDelete="true" />

            <asp:QueryExtender TargetControlID="GridDataSource" ID="GridQueryExtender" runat="server">
                <asp:DynamicFilterExpression ControlID="FilterRepeater" />
            </asp:QueryExtender>

            <br />
            <div class="DDBottomHyperLink">
                <asp:DynamicHyperLink ID="InsertHyperLink" runat="server" Action="Insert"><img runat="server" src="~/DynamicData/Content/Images/plus.gif" alt="Insert new item" />Insert new item</asp:DynamicHyperLink>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>

